import request from '@/utils/request'

export function getMenusTree() {
  return request({
    url: 'api/menus/tree',
    method: 'get'
  })
}

export function buildMenus() {
  return request({
    url: '/api/menu/getMenus',
    method: 'get'
  })
}

export function listMenu(data){
	return request({
	  url: '/api/menu/list',
	  method: 'get',
	  params: data
	})
}

export function getMenu(menuId){
	return request({
	  url: '/api/menu/getMenu/' + menuId,
	  method: 'get'
	})
}

// 修改菜单
export function updateMenu(data) {
  return request({
    url: '/api/menu/edit',
    method: 'post',
    data
  })
}

export function addMenu(data){
	return request({
	  url: '/api/menu/add',
	  method: 'post',
	  params: { ...data }
	})
}

export function delMenu(data){
	return request({
		url: 'api/menu/del',
		method: 'post',
		params: { ...data }
	})
}

// 根据角色ID查询菜单下拉树结构
export function roleMenuTreeselect(roleId) {
  return request({
    url: '/api/menu/roleMenuTreeselect/' + roleId,
    method: 'get'
  })
}

// 查询菜单下拉树结构
export function treeselect() {
  return request({
    url: '/api/menu/treeselect',
    method: 'get'
  })
}

export default { treeselect, roleMenuTreeselect, delMenu, addMenu, updateMenu, getMenusTree, listMenu, getMenu }
